/**
 * Copyright (c) 2018, wuyy All rights reserved.
 * wuyy 专有/保密源代码,未经许可禁止任何人通过任何渠道使用、修改源代码.
 * QQ:16349023
 * 项目名称 : com.wy2.eclipse.tool.ui
 * @version V1.0
 */
package com.wy2.eclipse.tool.ui.editors;

import org.eclipse.jface.viewers.ICheckStateProvider;
import com.wy2.generator.database.entity.DatabaseColumn;
import com.wy2.generator.database.entity.DatabaseTable;

/**
 * 数据生成选中提供者
 * @author wuyy<16349023@qq.com>
 * @date 2018年1月26日下午8:05:15
 * 
 */
public class TableCheckStateProvider implements ICheckStateProvider {

    /** 
     * @param element
     * @return 
     * @see org.eclipse.jface.viewers.ICheckStateProvider#isChecked(java.lang.Object)
     */
    @Override
    public boolean isChecked(Object element) {
        if(element instanceof DatabaseTable) {
            DatabaseTable table=(DatabaseTable) element;
            return table.getChecked();
        }else if(element instanceof DatabaseColumn) {
            DatabaseColumn column=(DatabaseColumn) element;
            return column.getChecked()!=null ? column.getChecked() : false;
        }
        return false;
    }

    /** 
     * @param element
     * @return 
     * @see org.eclipse.jface.viewers.ICheckStateProvider#isGrayed(java.lang.Object)
     */
    @Override
    public boolean isGrayed(Object element) {
        if(element instanceof DatabaseTable) {
            DatabaseTable table=(DatabaseTable) element;
            return false;
        }else if(element instanceof DatabaseColumn) {
            DatabaseColumn column=(DatabaseColumn) element;
            return false;
        }
        return false;
    }

}
